## 2019-04-11
## fuqiyang
## f@pear.hk

big_package="tmp_package.tar.gz"
sub_packages=$(patsubst update-data/%/,%.tar.gz,$(shell ls -d update-data/*/))

username?=tencent
sub_dirs=$(patsubst update-data/%/,update-data/%,$(shell ls -d update-data/*/))

## functions
##
define printf_color
	@echo "\033[33m${1}\033[0m"
endef


all : clean set_username create_platform_package create_big_package create_md5sum_package
	$(call printf_color,"finish...")

test:
	@echo ${sub_dirs}

set_username:
	for dir in ${sub_dirs};	\
	do						\
		sh .change_username.sh $${dir} ${username};	\
	done

create_platform_package :
	$(call printf_color,"[pack_update_data]")
	make -C ./update-data

create_big_package:
	@tar -zcvf ${big_package} ${sub_packages}

create_md5sum_package:
	CHECKSUM=$(shell md5sum ${big_package} | cut -d ' ' -f1); mv ${big_package} $$CHECKSUM.tar.gz

clean:
	@-rm -rf *tar.gz
	make -C ./update-data clean

help :
	$(call printf_color,"[help]")
	@echo "make [username=xxx] [clean]"

.PHONY : help clean create_platform_package create_big_package create_md5sum_package

